#include <CGalaxyComponentDisk.h>

double CGalaxyComponentDisk::calculateIntensity(double I, CVector& p, double iscale) {
    CVector P;
    double z;
    double rad = getRadius(p, P, z);
    //height = 1;
    double winding = getWinding(rad)*componentParams.winding;
    z = getHeightModulation(z);

    double shift = componentParams.arm*100.0;
    if (z>0.001) 
      {
	
	double armVal = 1.0;
	if (componentParams.arm!=0)
	  armVal =  calculateArmValue(rad, P, componentParams.arm);

	
	double intensity = getRadialIntensity(rad);
	

	
	//double p2 = 1.0-getPerlinCloudNoise(p, 1.0, winding*0.7, 10, 0.5, 1);
	
	double p2 = abs(getPerlinCloudNoise(p, 1.0, winding, 10, 0.5, componentParams.scale));
	params->diskStarModifier = p2;
       	//p2 = 1.0-(pow(0.6*p2,2));
	//p2 = pow(p2,0.5);
	
	double val =p2*25;
	double scale = CMath::SmoothStep(0, 2*params->bulgeDust, rad);

	//	scale = armVal*val*scale + 25*(1-scale);
	scale = armVal*scale*val + 25*(1-scale);
	// scale = armVal;

	//I += val;

	I+= strength*z*intensity*params->intensityScale*scale*iscale;
	
      }
    return I;
}
